            
class PointController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 10
        [ pointList: Point.list( params ) ]
    }

    def show = {
        def point = Point.get( params.id )

        if(!point) {
            flash.message = "Point not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ point : point ] }
    }

    def delete = {
        def point = Point.get( params.id )
        if(point) {
            point.delete()
            flash.message = "Point ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "Point not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def point = Point.get( params.id )

        if(!point) {
            flash.message = "Point not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ point : point ]
        }
    }

    def update = {
        def point = Point.get( params.id )
        if(point) {
            point.properties = params
            if(!point.hasErrors() && point.save()) {
                flash.message = "Point ${params.id} updated"
                redirect(action:show,id:point.id)
            }
            else {
                render(view:'edit',model:[point:point])
            }
        }
        else {
            flash.message = "Point not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def point = new Point()
        point.properties = params
        return ['point':point]
    }

    def save = {
        def point = new Point(params)
        if(!point.hasErrors() && point.save()) {
            flash.message = "Point ${point.id} created"
            redirect(action:show,id:point.id)
        }
        else {
            render(view:'create',model:[point:point])
        }
    }
}